﻿(function () {
    $(function () {
        $('#menu_editor_datagrid_menulist').treegrid({
            title: '菜单编辑',
            url: '/Content/Data/data.json',
            idField: 'id',
            method: 'get',
            treeField: 'name',
            animate: true,
            fit: true,
            toolbar: [{
                iconCls: 'icon-add',
                text: '添加',
                handler: function () { alert('edit') }
            }, {
                iconCls: 'icon-edit',
                text: '删除',
                handler: function () { alert('help') }
            }, {
                iconCls: 'icon-remove',
                text: '修改',
                handler: function () { alert('help') }
            }, {
                iconCls: 'icon-ok',
                text: '启用',
                handler: function () { alert('help') }
            }, {
                iconCls: 'icon-no',
                text: '禁用',
                handler: function () { alert('help') }
            }, {
                iconCls: 'icon-tip',
                text: '上移',
                handler: function () { alert('help') }
            }, {
                iconCls: 'icon-filter',
                text: '下移',
                handler: function () { alert('help') }
            }],
            columns: [[
                { title: '名称', field: 'name', width: 180 },
                { title: '图标', field: 'persons', width: 60, align: 'center' },
                { title: '地址', field: 'end', width: 80 },
                { title: '是否删除', field: 'begin', width: 80, align: 'center' },
                { title: '是否启用', field: 'begin', width: 80, align: 'center' }
            ]]
        });

        $('#menu_editor_window_menufrom').window({
            title: '菜单编辑',
            width: 600,
            height: 400,
            modal: true
        });

        $('#menu_editor_from_clear').linkbutton({
            iconCls: 'icon-search'
        });

        $('#menu_editor_from_clear').click(function () {

        });

        $('#menu_editor_from_save').linkbutton({
            iconCls: 'icon-search'
        });

        $('#menu_editor_from_save').click(function () {
            $('#menu_editor_from').form('submit', {
                url: '',
                onSubmit: function () {              
                    var isValid = $(this).form('validate');
                    if (!isValid) {
                        $.messager.progress('close'); // hide progress bar while the form is invalid
                    }
                    return isValid; // return false will stop the form submission
                },
                success: function () {
                    $.messager.progress('close'); // hide progress bar while submit successfully
                }
            });
        });
    });
} ());